//注释部分需要引入到组件中
// <empty-team title="暂无标签" v-if="empty"></empty-team>
//  <u-loadmore :status="status" v-if="!empty" />
//import pageMixin from '@/utils/pageMixin.js'  //在需要引入的组件中引入
export default {
	//mixins: [pageMixin],
	data() {
		return {
			empty: false,
			list: [],
			status: 'loading',
			pageNum: 1, //当前条目数
			totalCount: 0, //总条目数
			pageSize: 10000, //每页总条数
			avg: 0, //总页数
			first: true //标识
		}
	},
	onReady() {
		//this.getTeam()
	},
	onReachBottom() {
		setTimeout(()=>{
			this.getTeam()
		},500)
	},
	methods: {
		clearPageStatus() { //清空，当需要重新加载此分页时，先调用清空再调用请求
			this.list = []
			this.first = true
			this.status = 'loading';
			this.pageNum = 1 //当前条目数
			this.totalCount = 0 //总条目数
			this.avg = 0
		},
		// async getMyList(obj) { //请求,这个最好在使用那个组件中使用，这个地方可以扩展接参数
		//例如， {..obj,id:15}
		// 	let res = await getTeamByUser(obj)
		// 	this.teamNumber = res.total //单独需要赋值的地方
		// 	return res
		// },
		async getTeam() { //团队列表
			//console.log(this.pageNum , this.avg);
			let obj = {
				'pageNum': this.pageNum,
				'pageSize': this.pageSize,
			}
			//console.log(this.pageNum , this.avg && !this.first);
			if (this.pageNum > this.avg && !this.first) {
				this.status = 'nomore'
				return
			}
			if (this.pageNum == this.avg && this.status !== 'nomore') {
				let res = await this.getMyList(obj) //请求参数在上面拼接好最后
				if (res.code == 200) {
					this.first = false
					this.totalCount = res.total
					this.avg = Math.ceil(this.totalCount / this.pageSize)
					this.pageNum = ++this.pageNum
					this.list.push(...res.rows)
					this.status = 'nomore'
					if (this.list.length > 0) {
						this.empty = false
					} else {
						this.empty = true
					}
					return
				}
			}
			let res = await this.getMyList(obj) //请求参数在上面拼接好最后
			//console.log(res,'111');
			if (res.code == 200) {
				this.first = false
				this.totalCount = res.total
				this.avg = Math.ceil(this.totalCount / this.pageSize)
				this.list.push(...res.rows)
				this.pageNum = ++this.pageNum;
				this.status = 'loading';
				if(this.avg == 1){  //上来就一页，且不能翻页的情况下
					this.status = 'nomore'
				}
			}
			if (this.list.length > 0) {
				this.empty = false
			} else {
				this.empty = true
			}
		}
	}
}